package me.young.android.fullscreengesture

import android.content.SharedPreferences
import android.os.Bundle
import android.support.v7.preference.PreferenceFragmentCompat

class SettingFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener {

    companion object {
        const val KEY_PREF_LEFT_ENABLED = "enable_left"
        const val KEY_PREF_RIGHT_ENABLED = "enable_left"
        const val KEY_PREF_LEFT_WIDTH = "left_width"
        const val KEY_PREF_RIGHT_WIDTH = "right_width"
        const val KEY_PREF_VIBRATE_ENABLED = "vibrate_enabled"
        const val KEY_PREF_VIBRATE_MILLS = "vibrate_mill"
        const val KEY_PREF_QUICK_SWIPE = "quick_swipe"
        const val KEY_PREF_SWIPE_DISTANCE = "swipe_distance"
    }

    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
        addPreferencesFromResource(R.xml.pref_general)
        preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
    }

    override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
        FullScreenAccessService.sInstance?.reset()
    }

}